<template>
	<view class="container">
		<fu-navbar :title="repState == 1 ? '已失效' : repState == 2 ? '审核' : repState == 3 || repState == 4 ? '待领取' : repState == 9 ? '待指派' : repState == 10 ? '待验收' : repState == 11 ? '已验收' : repState == 6 ? '已分配' : ''" bgColor="#0f68f0" color="#fff"></fu-navbar>
		<view class="tit-box">
			<view class="title">报修信息</view>
			<view class="state">
				<image src="../../../static/images/icon18.png" mode="aspectFill" class="icon" v-if="form.urgencyLevel == 1 || form.urgencyLevel == 2"></image>
				<image src="../../../static/images/icon18.png" mode="aspectFill" class="icon" v-else></image>
				<text>{{form.urgencyLevelName}}</text>
			</view>
		</view>
		<view class="con-box">
			<view class="item border-b">
				<view class="label">报修单号：</view>
				<view class="con">{{form.workOrderCode || ''}}</view>
			</view>
			<view class="item border-b">
				<view class="label">设备编号：</view>
				<view class="con">{{form.emCode || ''}}</view>
			</view>
			<view class="item border-b">
				<view class="label">位置：</view>
				<view class="con">{{form.emLocation || ''}}</view>
			</view>
			<view class="item border-b">
				<view class="label">故障类别：</view>
				<view class="con">{{form.repFaultTypeName}}</view>
			</view>
			<view class="item border-b">
				<view class="label">设备状态：</view>
				<view class="con">{{form.repEmStateName || ''}}</view>
			</view>
			<view class="item border-b">
				<view class="label">故障描述：</view>
				<view class="con">{{form.repDesc || ''}}</view>
			</view>
			<view class="item border-b">
				<view class="label">报修人：</view>
				<view class="con flex align-center">
					<view class="flex-1 flex align-center text-ellipsis">
						<text style="margin-right: 24rpx;">{{form.repEmployeeName}}</text>
						<text class="text-ellipsis">{{form.repStartTime}}</text>
					</view>
					<image src="../../../static/images/icon21.png" mode="aspectFill" class="tel" @click="call(form.repEmployeeNum)"></image>
				</view>
			</view>
			<view class="item border-b">
				<view class="label">音频：</view>
				<view class="over-hidden con">
					<view class="flex align-center" @click="playAudio(item, index, 1)" v-for="(item, index) in form.audioList" :key="index">
						<image src="../../../static/images/play.png" mode="aspectFill" class="play" v-if="!item.isPlay"></image>
						<image src="../../../static/images/stop.png" mode="aspectFill" class="play" v-else></image>
						<view class="audio text-ellipsis">{{item.fileName}}</view>
					</view>
				</view>
			</view>
			<view class="item border-b">
				<view class="label">图片：</view>
				<view class="con flex align-center">
					<image class="img" :src="`${read_url}${item.fileCode}`" mode="aspectFill" v-for="(item, index) in form.picList" :key="index" @click="previewImg(item)"></image>
				</view>
			</view>
			<view class="item">
				<view class="label">视频：</view>
				<view class="con flex align-center">
					<block v-for="(item, index) in form.videoList" :key="index">
						<view class="v-img" v-if="!item.isPlay" @click="playVideo(1, index)">
							<image src="../../../static/images/no-img.png" mode="aspectFill" lazy-load class="img"></image>
							<image class="v-play" src="../../../static/images/video-bg.png"></image>
						</view>
						<video class="video" :src="`${read_url}${item.fileCode}`" :id="`myVideo${index}`" @fullscreenchange="fullscreenchange($event, index, 1)" @ended="videoEnd($event, index, 1)" v-else></video>
					</block>
				</view>
			</view>
		</view>
		
		<!-- 备件列表  + 基本信息-->
		
		<view v-if="repState == 2" class="bg-f padding-lr-24 margin-t-32" style="border-radius: 0 0 20rpx 20rpx;">
			<view class="flex align-center padding-tb-32 border-b-c9">
				<image src="../../../static/images/icon31.png" mode="widthFix" class="i-icon margin-r-24"></image>
				<text class="fs-32 text-bold">基本信息</text>
			</view>
			<view class="flex align-center padding-tb-32 border-b-e4 justify-between fs-28">
				<view>出库类型</view>
				<view class="flex align-center maxW-68" @click="toggleTab('selector')">
					<text class="text-ellipsis" v-if="typeValue">{{typeValue}}</text>
					<image src="../../../static/images/arrow-r.png" style="width: 32rpx;height: 32rpx; margin-left: 8rpx;"></image>
				</view>
			</view>
			<view class="flex padding-tb-32 border-b-e4 justify-between fs-28">
				<view class="flex-shrink">申请说明</view>
				<textarea placeholder="点击输入多行文本" placeholder-class="pla-tra" class="tra maxW-68" v-model="applyDesc"></textarea>
			</view>
		</view>
		<view v-if="repState == 2" class="margin-t-32 bg-f padding-lr-24" style="border-radius: 20rpx;">
			<view class="flex align-center padding-tb-32 border-b-c9 justify-between">
				<view class="flex align-center">
					<image src="../../../static/images/icon32.png" mode="widthFix" class="margin-r-24" style="width: 60rpx;"></image>
					<text class="fs-32 text-bold">备件列表</text>
				</view>
				<view class="flex align-center" @click="navTo('/pages/maintenance/select-part/index')">
					<image class="add-r-icon margin-r-12" src="../../../static/images/add.png" mode="aspectFill"></image>
					<text class="r-txt">选择备件</text>
				</view>
			</view>
			<view class="padding-tb-12">
				<del-slide-left v-for="(item, index) in partList" :key="index" :item="item"  :data_transit="{index:index,item:item}" @delItem="cancel(index)">
					<view class="itemList padding-tb-12">
						<view class="flex align-center justify-between over-hidden">
							<view class="fs-30 text-bold text-ellipsis">{{item.name}}</view>
							<view class="flex align-center flex-shrink">
								<view class="fs-30">当前库存：{{item.stock}}</view>
							</view>
						</view>
						<view class="flex over-hidden margin-t-24">
							<image src="../../../static/images/no-img.png" class="img flex-shrink" mode="aspectFill"></image>
							<view class="flex-1 over-hidden">
								<view class="fs-26 flex">
									<view class="label">编码：</view>
									<view class="text-ellipsis">{{item.code}}</view>
								</view>
								<view class="fs-26 flex">
									<view class="label">分类：</view>
									<view class="text-ellipsis">{{item.brand}}</view>
								</view>
								<view class="fs-26 flex">
									<view class="label">规格型号：</view>
									<view class="text-ellipsis">{{item.specs}}</view>
								</view>
							</view>
							<view class="flex-shrink flex align-end margin-b-12">
								<view class="flex align-center">
									<image src="../../../static/images/jian2.png" class="icon" @click="changeNum(item, index, 'sub')"></image>
									<view class="num">{{item.num}}</view>
									<image src="../../../static/images/jia2.png" class="icon" @click="changeNum(item, index, 'add')"></image>
								</view>
							</view>
						</view>
					</view>
				</del-slide-left>
				<view class="flex justify-center align-center" style="height: 200rpx;" v-if="partList.length == 0">
					<image src="../../../static/empty/no-data.png" mode="widthFix" style="width: 160rpx;"></image>
				</view>
			</view>
		</view>
		
		
		<block v-if="repState == 2 || repState == 3 || repState == 4 || repState == 11">
			<view class="tit-box">
				<view class="title">审核信息</view>
			</view>
			<view class="con-box yijian">
				<view class="item border-b" v-if="repState != 2">
					<view class="label">审核人：</view>
					<view class="con flex align-center text-ellipsis">
						<view style="margin-right: 24rpx;">{{audInfo.employeeName}}</view>
						<view class="text-ellipsis">{{audInfo.annTime}}</view>
					</view>
				</view>
				<view class="item border-b" v-if="repState == 3 || repState == 4 || repState == 11">
					<view class="label">审核：</view>
					<view class="con flex">
						<view class="audstate">{{audInfo.annStateName}}</view>
					</view>
				</view>
				<view class="item" v-if="repState == 3 || repState == 4 || repState == 11">
					<view class="label">审核意见：</view>
					<view class="con">{{audInfo.annExplain}}</view>
				</view>
				<block v-if="repState == 2">
					<view class="flex align-center justify-between padding-tb-24 fs-28 border-b" @click="toggleTab('hour')">
						<view>预计工时</view>
						<view class="flex align-center">
							<view>{{estimatedWorkHour}}</view>
							<image src="../../../static/images/arrow-r.png" class="arrow-r" style="width: 32rpx;height: 32rpx;margin-left: 8rpx;"></image>
						</view>
					</view>
					<view class="item" style="align-items: flex-start;">
						<view class="label">审核意见：</view>
						<view class="con">
							<textarea class="ipt" placeholder="请输入" v-model="annExplain" />
						</view>
					</view>
				</block>
			</view>
		</block>
		
		<block v-if="repState == 9 || repState == 10 || repState == 11">
			<view class="tit-box">
				<view class="title">维修信息</view>
			</view>
			<view class="con-box">
				<view class="item border-b">
					<view class="label">故障类型：</view>
					<view class="con">{{mainInfo.mtcFaultTypeName}}</view>
				</view>
				<view class="item border-b">
					<view class="label">故障原因：</view>
					<view class="con">{{mainInfo.mtcFaultReasonName || ''}}</view>
				</view>
				<view class="item border-b">
					<view class="label">设备状态：</view>
					<view class="con">{{mainInfo.mtcEmStateName || ''}}</view>
				</view>
				<view class="item border-b">
					<view class="label">处理方法及结果：</view>
					<view class="con">{{mainInfo.mtcDesc || ''}}</view>
				</view>
				<view class="item border-b">
					<view class="label">维修人：</view>
					<view class="con flex align-center">
						<view class="flex-1 flex align-center text-ellipsis">
							<text style="margin-right: 24rpx;">{{mainInfo.employeeName}}</text>
							<text class="text-ellipsis">{{mainInfo.mtcStartTime}}</text>
						</view>
						<image src="../../../static/images/icon21.png" mode="aspectFill" class="tel" @click="call()"></image>
					</view>
				</view>
				<view class="item border-b">
					<view class="label">语音：</view>
					<view class="con flex align-center" @click="playAudio(item, index, 2)" v-for="(item, index) in mainInfo.audioNewList" :key="index">
						<image src="../../../static/images/play.png" mode="aspectFill" class="play" v-if="!item.isPlay"></image>
						<image src="../../../static/images/stop.png" mode="aspectFill" class="play" v-else></image>
						<view class="audio text-ellipsis">{{item.fileName}}</view>
					</view>
				</view>
				<view class="item border-b">
					<view class="label">图片：</view>
					<view class="con flex align-center">
						<image class="img" :src="`${read_url}${item.fileCode}`" mode="aspectFill" v-for="(item, index) in mainInfo.picNewList" :key="index" @click="previewImg(item)"></image>
					</view>
				</view>
				<view class="item">
					<view class="label">视频：</view>
					<view class="con flex align-center">
						<block v-for="(item, index) in mainInfo.videoNewList" :key="index">
							<view class="v-img" v-if="!item.isPlay" @click="playVideo(2, index)">
								<image src="" mode="aspectFill" lazy-load class="img"></image>
								<image class="v-play" src="../../../static/images/video-bg.png"></image>
							</view>
							<video class="video" :src="`${read_url}${item.fileCode}`" :id="`wxVideo${index}`" @fullscreenchange="fullscreenchange($event, index, 2)" @ended="videoEnd($event, index, 2)" v-else></video>
						</block>
					</view>
				</view>
			</view>
		</block>
		<view style="height: 24rpx;"></view>
		<block v-if="repState == 11">
			<view class="tit-box">
				<view class="title">验收信息</view>
			</view>
			<view class="con-box yijian">
				<view class="item border-b">
					<view class="label">验收人：</view>
					<view class="con flex align-center text-ellipsis">
						<view style="margin-right: 24rpx;">{{acceptInfo.employeeName}}</view>
						<view class="text-ellipsis">{{acceptInfo.acceptTime}}</view>
					</view>
				</view>
				<view class="item border-b">
					<view class="label">验收结果：</view>
					<view class="con flex">
						<view class="audstate">{{acceptInfo.acceptStateName}}</view>
					</view>
				</view>
			</view>
		</block>
		<!-- <view class="con-box" v-if="repState == 9 || repState == 10 || repState == 11">
			<view class="item border-b">
				<view class="label">维修评分：</view>
				<view class="con">{{mainInfo.repDesc || ''}}</view>
			</view>
			<view class="item border-b">
				<view class="label">维修评价：</view>
				<view class="con">{{mainInfo.repDesc || ''}}</view>
			</view>
		</view> -->
		<view class="bottom-wrap" v-if="repState != 11">
			<view class="bottom justify-between" v-if="repState == 2">
				<view class="btn left" @click="auditing(2)">审核驳回</view>
				<view class="btn right" @click="auditing(1)">审核通过</view>
			</view>
			<view class="bottom justify-center" v-if="repState == 3 && state == 3">
				<view class="btn lingqu" @click="receive(1)">领取</view>
			</view>
			<view class="bottom justify-center" v-if="repState == 4 || (repState == 3 && state == 4)">
				<view class="btn zhipai" @click="zhipai">指派</view>
			</view>
			<view class="bottom justify-between" v-if="repState == 6">
				<view class="btn left" @click="refuse()">拒单</view>
				<view class="btn right" @click="suspend()">维修开始</view>
			</view>
			<view class="bottom justify-center" v-if="repState == 9">
				<view class="btn right" @click="ysZhipai">验收指派</view>
			</view>
			<view class="bottom justify-between" v-if="repState == 10">
				<view class="btn left" @click="accept(2)">验收驳回</view>
				<view class="btn right" @click="accept(1)">验收通过</view>
			</view>
		</view>
		
		<!-- 预计时长 -->
		<w-picker mode="selector" :options="hourList" themeColor="#30a3e0" @confirm="onConfirm($event, 'hour')" ref="hour" :value="estimatedWorkHour"></w-picker>
		
		<w-picker mode="selector" :options="typeList" themeColor="#30a3e0" :defaultProps="defaultProps" @confirm="onConfirmType($event, 'selector')" ref="selector"></w-picker>
	</view>
</template>

<script>
import fuNavbar from '@/components/fu-navbar/fu-navbar.vue';
import {READ_FILE_URL} from '@/common/config.js';
import delSlideLeft from '@/components/delSlideLeft/delSlideLeft.vue';
const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.src = ''
export default {
	components: {
		fuNavbar,
		delSlideLeft
	},
	data() {
		return {
			repState: 0,
			audioShow: false,
			audioShow2: false,
			repId: 0,
			form: {},
			audInfo: {},
			state: '',
			mainInfo: {},
			pid: 0,
			videoContext: null,
			videoContext2: null,
			acceptInfo: {},
			isPlay: false,
			read_url: READ_FILE_URL,
			annExplain: '',
			estimatedWorkHour: '03:00',
			hourList: [],
			isStart: false,
			partList: [], //备件列表
			typeList: [], //备件列表
			outType: null,
			applyDesc: '',
			typeValue: '',
			defaultProps: {
				value: 'dictValue',
				label: 'dictName'
			},
		}
	},
	onLoad(option) {
		this.repState = option.repState
		this.repId = option.repId
		this.state = option.state
		this.getData();
		this.getAnnounce();
		this.getMaintenance();
		this.getAccept();
		this.getHour();
		this.getOutType();
		uni.$on('getPerId', data => {
			this.pid = data.id
		})
		
		uni.$on('getPart', arr => {
			arr.forEach(item => {
				item.num = 1
				this.partList.push(item)
			})
		})
	},
	onShow() {
		
	},
	onReady() {
		this.videoContext = uni.createVideoContext('myVideo');
		this.videoContext2 = uni.createVideoContext('wxVideo');
	},
	onUnload() {
		uni.$off('getPerId')
		uni.$off('getPart')
	},
	methods: {
		updateApply(id) {
			this.$api.post(global.apiUrls.updatePartApplyState, {
				id: id,
				operation: 1
			}).then(res => {
				if (res.data.code == 9100) {
					uni.showToast({
						title: '操作成功',
						icon: 'none'
					})
					setTimeout(() => {
						uni.switchTab({
							url: '/pages/tab/home/index'
						})
					}, 800)
					
				} else {
					uni.showToast({
						title: res.data.msg,
						icon: 'none'
					})
				}
			})
		},
		sparePartsApi(){
			let arr = []
			this.partList.forEach(item => {
				let obj = {
					partId: item.id,
					num: item.num
				}
				arr.push(obj)
			})
			this.$api.post(global.apiUrls.insertPartApply, {
				outType: this.outType,
				applyDesc: this.applyDesc,
				data: JSON.stringify(arr),
				businessCode: this.form.workOrderCode,
				businessId: this.form.repId
			}).then(res => {
				if (res.data.code == 9100) {
					let id = res.data.info
					this.updateApply(id)
				} else {
					uni.showToast({
						title: res.data.msg,
						icon: 'none'
					})
				}
			})
		},
		navTo(path) {
			uni.navigateTo({
				url:path
			})
		},
		onConfirmType(e) {
			this.typeValue = e.result
			this.outType = e.value
		},
		cancel(i) {
			this.partList.splice(i, 1)
		},
		changeNum(e, i, type) {
			if (type == 'sub') {
				if (e.num == 1) return
				this.partList[i].num--
			} else {
				if (e.num == e.stock) {
					uni.showToast({
						title: '暂无库存',
						icon: 'none'
					})
				} else {
					this.partList[i].num++
				}
			}
			this.$forceUpdate();
		},
		toggleTab(ref, index) {
		  this.$refs[ref].show();
		},
		getOutType() {
			this.$api.post(global.apiUrls.selectType, {
				dictTypeCode: 'TYPE_PART_OUT_TYPE'
			}).then(res => {
				if (res.data.code == 9100) {
					this.typeList = res.data.info
				}
			})
		},
		onConfirm(e, type) {
			if (type == 'hour') {
				this.estimatedWorkHour = e.result
			}
		},
		getHour() {
			let arr = [];
			let timeArrays = new Array(48).fill(['', '']).map((item, index) => {
			    let startVal = index * 30;
			    let endVal = (index + 1) * 30;
			    let startHour = Math.floor((startVal / 60));
			    let startMinute = (startVal % 60);
			    let endHour = Math.floor((endVal / 60));
			    let endMinute = (endVal % 60);
			    let startTime = ((startHour < 10) ? ('0' + startHour) : startHour) + ':' + (startMinute === 0 ? '00' : startMinute);
			    let endTime = ((endHour < 10) ? ('0' + endHour) : endHour) + ':' + (endMinute === 0 ? '00' : endMinute);
				let obj = {
					label: endTime
				}
			    arr.push(obj)
			});
			this.hourList = arr
		},
		previewImg(item) {
			uni.previewImage({
				urls: [`${READ_FILE_URL}${item.fileCode}`]
			})
		},
		playAudio(e, i, type) {
			if (type == 1) {
				if (this.mainInfo.audioNewList) {
					this.mainInfo.audioNewList.forEach(res => {
						res.isPlay = false
					})
				}
				this.form.audioList[i].isPlay = !this.form.audioList[i].isPlay
				innerAudioContext.src = `${READ_FILE_URL}${e.fileCode}`
				console.log(this.form.audioList[i], 111111)
				if (this.form.audioList && this.form.audioList[i].isPlay) {
					this.form.audioList.forEach((res, index) => {
						if (index !== i) {
							res.isPlay = false
						}
					})
					innerAudioContext.play();
					this.$forceUpdate();
				} else if (this.form.audioList && !this.form.audioList[i].isPlay) {
					this.form.audioList.forEach((res, index) => {
						res.isPlay = false
					})
					innerAudioContext.pause();
					this.$forceUpdate();
				}
				innerAudioContext.onEnded(() => {
					this.form.audioList[i].isPlay = false
					this.$forceUpdate();
				})
			} else if (type == 2) {
				if (this.form.audioList) {
					this.form.audioList.forEach(res => {
						res.isPlay = false
					})
				}
				this.mainInfo.audioNewList[i].isPlay = !this.mainInfo.audioNewList[i].isPlay
				innerAudioContext.src = `${READ_FILE_URL}${e.fileCode}`
				if (this.mainInfo.audioNewList[i].isPlay) {
					this.mainInfo.audioNewList.forEach((res, index) => {
						if (index !== i) {
							res.isPlay = false
						}
					})
					innerAudioContext.play();
					this.$forceUpdate();
				} else {
					this.mainInfo.audioNewList.forEach((res, index) => {
						res.isPlay = false
					})
					innerAudioContext.pause();
					this.$forceUpdate();
				}
				innerAudioContext.onEnded(() => {
					this.mainInfo.audioNewList[i].isPlay = false
					this.$forceUpdate();
				})
			}
			
		},
		playVideo(e, i) {
		  // this.isPlay = true;
		  let that = this;
		  if (e == 1) {
			  this.videoContext = uni.createVideoContext(`myVideo${i}`);
			  this.form.videoList[i].isPlay = true
			  setTimeout(() => {
			    that.videoContext.requestFullScreen(0);
			    that.videoContext.play();
			  }, 200);
		  } else {
			  this.videoContext2 = uni.createVideoContext(`wxVideo${i}`);
			  this.mainInfo.videoNewList[i].isPlay = true
			  setTimeout(() => {
			    that.videoContext2.requestFullScreen(0);
			    that.videoContext2.play();
			  }, 200);
		  }
		  this.$forceUpdate();
		},
		fullscreenchange(e, i, type) {
			console.log(e);
			// 退出全屏时
			if (!e.detail.fullScreen) {
				if (type == 1) {
					this.form.videoList[i].isPlay = false
					this.videoContext.pause();
				} else {
					this.mainInfo.videoNewList[i].isPlay = false
					this.videoContext2.pause();
				}
			}
			this.$forceUpdate();
		},
		videoEnd(e, i, type) {
			if (type == 1) {
				this.videoContext.exitFullScreen();
				this.form.videoList[i].isPlay = false
			} else {
				this.videoContext2.exitFullScreen();
				this.mainInfo.videoNewList[i].isPlay = false
			}
			this.$forceUpdate();
		},
		call(num) {
			uni.makePhoneCall({
				phoneNumber: num
			})
		},
		getData() {
			this.$api.post(global.apiUrls.getBasicRepairById, {
				repId: this.repId
			}).then(res => {
				if (res.data.code == 9100) {
					this.repState = res.data.info.repState
					this.form = res.data.info
					this.form.audioList.forEach(item => {
						item.isPlay = false
					})
					this.form.videoList.forEach(item => {
						item.isPlay = false
					})
					if (this.isStart) {
						uni.redirectTo({
							url: `/pages/service/order-detail/my-order?repState=${this.repState}&repId=${this.form.repId}`
						})
					}
				} else {
					uni.showToast({
						title: res.data.msg,
						icon: 'none'
					})
				}
			})
		},
		// 获取审核信息
		getAnnounce() {
			this.$api.post(global.apiUrls.getAnnounceRepairById, {
				repId: this.repId,
				repState: this.repState
			}).then(res => {
				if (res.data.code == 9100) {
					this.audInfo = res.data.info
				}
			})
		},
		// 查询维修信息
		getMaintenance() {
			this.$api.post(global.apiUrls.getMaintenanceRepairById, {
				repId: this.repId,
				repState: this.repState
			}).then(res => {
				if (res.data.code == 9100) {
					this.mainInfo = res.data.info
					if (this.mainInfo.audioNewList) {
						this.mainInfo.audioNewList.forEach(item => {
							item.isPlay = false
						})
						this.mainInfo.videoNewList.forEach(item => {
							item.isPlay = false
						})
					}
				}
			})
		},
		// 查询验收信息
		getAccept() {
			if (this.repState == 11) {
				this.$api.post(global.apiUrls.getAcceptById, {
					repId: this.repId,
					repState: this.repState
				}).then(res => {
					if (res.data.code == 9100) {
						this.acceptInfo = res.data.info
					}
				})
			}
		},
		// 时间段转换分钟数
		timeToMin(timeStr) {
			let parts = timeStr.split(":")
			let hour = parseInt(parts[0], 10)
			let min = parseInt(parts[1], 10)
			return hour*60 + min
		},
		auditing(e) {
			if(e == '1') {
				if (!this.outType) {
					uni.showToast({
						title: '请选择出库类型',
						icon: 'none'
					})
					return
				}
				if (this.partList.length == 0) {
					uni.showToast({
						title: '请选择出库备件',
						icon: 'none'
					})
					return
				}
			}
			this.$api.post(global.apiUrls.insertAnnounceByRep, {
				sourceId: this.form.repId,
				annState: e,
				annExplain: this.annExplain,
				estimatedWorkHour: this.timeToMin(this.estimatedWorkHour)
			}).then(res => {
				if (res.data.code == 9100) {
					uni.showToast({
						title: '操作成功',
						icon: 'none'
					})
					if(e == 1 && this.repState == '2'){
						this.sparePartsApi()
					}
					if(e == 2) {
						setTimeout(() => {
							uni.switchTab({
								url: '/pages/tab/home/index'
							})
						}, 800)
					}
					
				} else {
					uni.showToast({
						title: res.data.msg,
						icon: 'none'
					})
				}
			})
		},
		// 领取
		receive(e) {
			this.$api.post(global.apiUrls.receiveRepair, {
				repId: this.form.repId,
				receiveType: e, //1自己领取 2领导派单
				employeeId: this.pid //指派的维修人员id
			}).then(res => {
				if (res.data.code == 9100) {
					uni.showToast({
						title: '操作成功',
						icon: 'none'
					})
					setTimeout(() => {
						// uni.navigateBack()
						let title = '我处理的'
						let state = 6
						uni.redirectTo({
							url: `/pages/service/order/index?title=${title}&state=${state}`
						})
					}, 800)
				} else {
					uni.showToast({
						title: res.data.msg,
						icon: 'none'
					})
				}
			})
		},
		zhipai() {
			uni.navigateTo({
				url: `/pages/service/select-per/index?orderId=${this.form.repId}&type=repReceive`
			})
		},
		ysZhipai() {
			uni.navigateTo({
				url: `/pages/service/select-per/index?orderId=${this.mainInfo.id}&type=rep`
			})
		},
		// 拒单
		refuse() {
			this.$api.post(global.apiUrls.refuseRepair, {
				id: this.mainInfo.id
			}).then(res => {
				if (res.data.code == 9100) {
					uni.showToast({
						title: '操作成功',
						icon: 'none'
					})
					setTimeout(() => {
						uni.navigateBack()
					}, 800)
				} else {
					uni.showToast({
						title: res.data.msg,
						icon: 'none'
					})
				}
			})
		},
		suspend() {
			this.$api.post(global.apiUrls.undeRepair, {
				id: this.mainInfo.id
			}).then(res => {
				if (res.data.code == 9100) {
					uni.showToast({
						title: '操作成功',
						icon: 'none'
					})
					this.isStart = true
					this.getData();
				} else {
					uni.showToast({
						title: res.data.msg,
						icon: 'none'
					})
				}
			})
		},
		accept(e) {
			uni.navigateTo({
				url: `/pages/service/accept/index?type=${e}&orderId=${this.mainInfo.id}&title=维修验收&orderType=rep`
			})
		}
	}
}
</script>

<style lang="scss" scoped>
.container {
	min-height: 100vh;
	background-color: #f3f5f8;
}
.tit-box {
	padding: 24rpx;
	display: flex;
	.title {
		flex: 1;
		font-weight: bold;
		font-size: 32rpx;
	}
	.state {
		display: flex;
		align-items: center;
		flex-shrink: 0;
		.icon {
			width: 42rpx;
			height: 42rpx;
			margin-right: 8rpx;
		}
		text {
			font-size: 26rpx;
			color: #f85d76;
		}
	}
}
.con-box {
	background-color: #fff;
	padding: 0 24rpx;
	.item {
		padding: 24rpx 0;
		display: flex;
		align-items: center;
		flex-wrap: wrap;
		font-size: 28rpx;
		.label {
			width: 260rpx;
			margin-right: 16rpx;
			flex-shrink: 0;
		}
		.con {
			flex: 1;
			word-wrap: break-word;
			overflow: hidden;
			.tel {
				width: 40rpx;
				height: 40rpx;
				flex-shrink: 0;
			}
			.play {
				width: 32rpx;
				height: 32rpx;
				flex-shrink: 0;
				margin-right: 12rpx;
			}
			.audio {
				color: #6c8bb6;
				text-decoration: underline;
			}
			.img {
				width: 150rpx;
				height: 100rpx;
				margin-right: 12rpx;
			}
			.v-img {
				width: 150rpx;
				height: 100rpx;
				margin-right: 12rpx;
				position: relative;
				.img {
					width: 100%;
					height: 100%;
					background-color: #000;
				}
				.v-play {
					position: absolute;
					width: 44rpx;
					height: 44rpx;
					top: 0;
					bottom: 0;
					left: 0;
					right: 0;
					margin: auto;
				}
			}
			.video {
				width: 150rpx;
				height: 100rpx;
				margin-right: 12rpx;
			}
			.audstate {
				background-color: #0f68f0;
				border-radius: 16rpx;
				color: #fff;
				display: inline-block;
				padding: 0 10rpx;
			}
			.ipt {
				height: 180rpx;
				border: 1rpx solid #c3c3c3;
				border-radius: 16rpx;
				padding: 12rpx;
				font-size: 28rpx;
				width: 100%;
				box-sizing: border-box;
			}
		}
	}
}
.yijian {
	min-height: 100rpx;
}
.bottom-wrap {
	height: 160rpx;
	.bottom {
		padding: 24rpx 32rpx;
		position: fixed;
		bottom: 0;
		height: 160rpx;
		box-sizing: border-box;
		display: flex;
		width: 100%;
		.btn {
			width: 256rpx;
			height: 80rpx;
			border-radius: 10rpx;
			text-align: center;
			line-height: 80rpx;
			color: #fff;
			font-size: 36rpx;
		}
		.left {
			background-color: #d9001b;
		}
		.right {
			background-color: #0f68f0;
		}
		.lingqu {
			background-color: #f85d76;
		}
		.zhipai {
			background-color: #f59a23;
		}
	}
}
.border-b {
	border-bottom: 1rpx solid #f2f2f2;
}

.i-icon {
	width: 40rpx;
}
.pla-tra {
	color: #ccc;
}
.tra {
	height: 160rpx;
	font-size: 28rpx;
}
.maxW-68 {
	max-width: 68%;
}
.add-r-icon {
	width: 42rpx;
	height: 42rpx;
}
.r-txt {
	color: #1296db;
	font-size: 28rpx;
}
.itemList {
	.label {
		width: 136rpx;
		text-align: right;
		flex-shrink: 0;
	}
	.img {
		width: 100rpx;
		height: 100rpx;
		margin-right: 12rpx;
	}
	.icon {
		width: 32rpx;
		height: 32rpx;
	}
	.num {
		width: 70rpx;
		border: 1rpx solid #b4b4b4;
		margin: 0 12rpx;
		font-size: 26rpx;
		text-align: center;
	}
}
</style>